﻿using System;

using System.Windows.Forms;

namespace HRM
{
    public partial class frmEmployeeReport : Form
    {
        #region Parameter
        string _GradeID;
        public string GradeID
        {
            get { return _GradeID; }
            set { _GradeID = value; }
        }

        string _FromAgeID;
        public string FromAgeID
        {
            get { return _FromAgeID; }
            set { _FromAgeID = value; }
        }

        string _ToAgeID;
        public string ToAgeID
        {
            get { return _ToAgeID; }
            set { _ToAgeID = value; }
        }

        string _Sex;
        public string Sex
        {
            get { return _Sex; }
            set { _Sex = value; }
        }

        string _BranchID;
        public string BranchID
        {
            get { return _BranchID; }
            set { _BranchID = value; }
        }

        string _DepartmentID;
        public string DepartmentID
        {
            get { return _DepartmentID; }
            set { _DepartmentID = value; }
        }

        string _Month;
        public string Month
        {
            get { return _Month; }
            set { _Month = value; }
        }

        string _Year;
        public string Year
        {
            get { return _Year; }
            set { _Year = value; }
        }

        string _ReportType;
        public string ReportType
        {
            get { return _ReportType; }
            set { _ReportType = value; }
        }

        string _ReportText;
        public string ReportText
        {
            get { return _ReportText; }
            set { _ReportText = value; }
        }
        string _ToMonth;
        public string ToMonth
        {
            get { return _ToMonth; }
            set { _ToMonth = value; }
        }
        string _ToYear;
        public string ToYear
        {
            get { return _ToYear; }
            set { _ToYear = value; }
        }
        int _DangVien;
        public int DangVien
        {
            get { return _DangVien; }
            set { _DangVien = value; }
        }
        #endregion

        public frmEmployeeReport()
        {
            InitializeComponent();
            //LoadLanguage();
            UISetting.LoadBranch(ref cboBranch);
            UISetting.LoadAge(ref cboFromAge);
            cboFromAge.SelectedValue = 18;
            UISetting.LoadAge(ref cboToAge);
            cboToAge.SelectedValue = 65;
            //UISetting.LoadGrade(ref cboGrade, Program.intBranchID);
            UISetting.LoadMonths(ref cboMonth);
            cboMonth.SelectedValue = Convert.ToInt32(DateTime.Now.Month);
            UISetting.LoadYears(ref cboYear);
            cboYear.SelectedValue = Convert.ToInt32(DateTime.Now.Year);
            UISetting.LoadMonths(ref cboToMonth);
            cboToMonth.SelectedValue = Convert.ToInt32(DateTime.Now.Month);
            UISetting.LoadYears(ref cboToYear);
        }
        void LoadLanguage()
        {
            if (this.Tag != null)
                this.Text = UpdateUI.GetString(this.Tag.ToString());
            UpdateUI.Load_Panel(ref panel2);
            UpdateUI.Load_Panel(ref panel3);

        }
        private void btnView_Click(object sender, EventArgs e)
        {
            _BranchID = cboBranch.SelectedValue.ToString();
            _DepartmentID = cboDepartment.SelectedValue.ToString();
            _FromAgeID = cboFromAge.SelectedValue.ToString(); ;
            _ToAgeID = cboToAge.SelectedValue.ToString();
            _GradeID = cboGrade.SelectedValue.ToString();
            _Month = cboMonth.SelectedValue.ToString();
            _Year = cboYear.SelectedValue.ToString();
            _ToMonth = cboToMonth.SelectedValue.ToString();
            _ToYear = cboToYear.SelectedValue.ToString();
            if (radNam.Checked == false && radNu.Checked == false)
                _Sex = "";
            else if (radNam.Checked)
                _Sex = "true";
            else
                _Sex = "false";

            if (radEmployeeList.Checked)
            {
                _ReportText = "danhsachcanbo";
                _ReportType = "EmployeeList";
            }

            //if (rdnPayrollSummary.Checked)
            //{
            //    _ReportText = "bangluongtong";
            //    _ReportType = "PayrollSummary";
            //}

            //if (rdnPayrollDetail.Checked)
            //{
            //    if (Convert.ToInt32(_DepartmentID) > 0)
            //    {
            //        _ReportText = "bangluongchitiet";
            //        _ReportType = "PayrollDetail";
            //    }
            //    else
            //    {
            //        MessageBox.Show(UpdateUI.GetString("chuachonphongban"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        return;
            //    }
            //}
            //if (rdnPayrollSendtoBank.Checked)
            //{
            //    _ReportText = "bangluongguinganhang";
            //    _ReportType = "PayrollSendToBank";
            //}
            //if (rdnPaySlip.Checked)
            //{
            //    _ReportText = "tienluongghep";
            //    _ReportType = "PaySlip";
            //}
            if (radDangVien.Checked)
            {
                _DangVien = 1;
                _ReportText = "DS đảng viên";
                _ReportType = "DSDangVien";
            }
            if (radQuanNhanPhucVien.Checked)
            {
                _DangVien = 2;
                _ReportText = "DS quân nhân phục viên";
                _ReportType = "DSQuanNhanPhucVien";
            }
            if (radFamily.Checked)
            {
                _ReportText = "soluongnhanvien";
                _ReportType = "NumberofEmployee";
            }
            if (rdnlaodong6thang.Checked)
            {
                _ReportText = "LaoDong6thang";
                _ReportType = "LaoDong6thang";
            }
            if (rdnlaodongcacnam.Checked)
            {
                _ReportText = "LaoDongCacnam";
                _ReportType = "LaoDongCacnam";
            }
            if (radMarkWork.Checked)
            {
                if (Convert.ToInt32(_BranchID) > 0)
                {
                    _ReportText = "Bảng chấm công";
                    _ReportType = "BangChamCong";
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("chuachonchinhanh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (radTotalMarkWork.Checked)
            {
                if (Convert.ToInt32(_BranchID) > 0)
                {
                    _ReportText = "Tổng hợp bảng chấm công";
                    _ReportType = "TongHopBangChamCong";
                }
                else
                {
                    MessageBox.Show(UpdateUI.GetString("chuachonchinhanh"), UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (radEmployeeDescrease.Checked)
            {
                _ReportText = "GiamLaoDong";
                _ReportType = "EmployeeDescrease";
            }
            if (radKhaiBaoLaoDong.Checked)
            {
                _ReportText = "KhaiBaoSuDungLaoDong";
                _ReportType = "KhaiBaoSuDungLD";
            }
            if (radStandard.Checked)
            {
                _ReportText = "Lực lượng lao động";
                _ReportType = "TrinhDoLaoDong";
            }
            if (radWorkingBachground.Checked)
            {
                _ReportText = "DS kinh nghiệm làm việc";
                _ReportType = "danhsachkinhnghiem";
            }
            if (radPositionDetail.Checked)
            {
                _ReportText = "DSQT lương";
                _ReportType = "danhsachquatrinhluong";
            }
            if (radLabourContract.Checked)
            {
                _ReportText = "DSQT ký HĐ";
                _ReportType = "danhsachhopdong";
            }
            if (radEducation.Checked)
            {
                _ReportText = "DSQT đào tạo";
                _ReportType = "danhsachdaotao";
            }
            if (radGrade.Checked)
            {
                _ReportText = "DSQT chức danh";
                _ReportType = "danhsachchucdanh";
            }

            if (radFamily.Checked)
            {
                _ReportText = "DS quan hệ gia đình";
                _ReportType = "danhsachgiadinh";
            }

            if (radhv.Checked)
            {
                _ReportText = "DS học việc, thử việc";
                _ReportType = "DSthuviechocviec";
            }

            this.DialogResult = DialogResult.OK;
        }
        private void cboBranch_SelectedIndexChanged(object sender, EventArgs e)
        {
            UISetting.LoadDepartment(ref cboDepartment, Convert.ToInt32(cboBranch.SelectedValue));
            UISetting.LoadGrade(ref cboGrade, Convert.ToInt32(cboBranch.SelectedValue));
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }


        void ShowEmployee(bool retval)
        {
            cboGrade.Enabled = radNam.Enabled = radNu.Enabled = cboFromAge.Enabled = cboToAge.Enabled = retval;
        }
        void ShowSalary(bool retVal)
        {
            cboMonth.Enabled = cboYear.Enabled = retVal;
        }

        void ShowDepartment(bool retVal)
        {
            cboDepartment.Enabled = retVal;
            if (!retVal)
                cboDepartment.SelectedValue = 0;
        }

        private void radEmployeeList_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            //ShowSalary(true);
            ShowDepartment(true);
            ShowEmployee(true);
            cboToMonth.Enabled = true;
            cboToYear.Enabled = true;
            cboMonth.Enabled = true;
            cboYear.Enabled = true;
            label2.Text = "Từ tháng";
        }
        private void rdnPayrollSummary_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(true);
            ShowEmployee(false);
            ShowDepartment(false);
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
        }

        private void rdnPayrollSendtoBank_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(true);
            ShowEmployee(false);
            ShowDepartment(false);
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
        }

        private void rdnPayrollDetail_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(true);
            ShowEmployee(false);
            ShowDepartment(true);
        }
        private void rdnPaySlip_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(true);
            ShowEmployee(false);
            ShowDepartment(true);
        }
        private void frmEmployeeReport_Load(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            if (radEmployeeList.Checked)
            {
                ShowSalary(true);
                ShowDepartment(true);
                ShowEmployee(true);
            }
        }

        private void rdnNumberOfEmp_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = false;
            ShowSalary(false);
            ShowEmployee(false);
            ShowDepartment(false);
        }

        private void rdnlaodong6thang_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(false);
            ShowEmployee(false);
            ShowDepartment(false);
            cboYear.Enabled = true;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
        }
        private void rdnlaodongcacnam_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(false);
            ShowEmployee(false);
            ShowDepartment(false);
            cboYear.Enabled = true;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
        }



        private void radEmployeeDescrease_CheckedChanged(object sender, EventArgs e)
        {

            cboBranch.Enabled = true;
            ShowSalary(false);
            ShowEmployee(false);
            ShowDepartment(false);
            cboYear.Enabled = true;
            cboMonth.Enabled = true;
            cboToMonth.Enabled = true;
            cboToYear.Enabled = true;
            cboMonth.Enabled = true;
            cboYear.Enabled = true;
            label2.Text = "Từ tháng";

        }

        private void radKhaiBaoLaoDong_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowSalary(false);
            ShowEmployee(false);
            ShowDepartment(false);
            cboYear.Enabled = true;
            cboMonth.Enabled = true;
            cboToMonth.Enabled = true;
            cboToYear.Enabled = true;
            cboMonth.Enabled = true;
            cboYear.Enabled = true;
            label2.Text = "Từ tháng";

        }

        private void radMarkWork_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(true);
            cboYear.Enabled = true;
            cboMonth.Enabled = true;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radStandard_CheckedChanged(object sender, EventArgs e)
        {

            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = true;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radEducation_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radGrade_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radWorkingBachground_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";

        }

        private void radPositionDetail_CheckedChanged(object sender, EventArgs e)
        {

            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radLabourContract_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";

        }

        private void radFamily_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radhv_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(false);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
            label2.Text = "Tháng";
        }

        private void radDangVien_CheckedChanged(object sender, EventArgs e)
        {
            cboBranch.Enabled = true;
            ShowDepartment(true);
            cboYear.Enabled = false;
            cboMonth.Enabled = false;
            cboGrade.Enabled = false;
            cboFromAge.Enabled = false;
            cboToAge.Enabled = false;
            radNam.Enabled = radNu.Enabled = false;
            cboToMonth.Enabled = false;
            cboToYear.Enabled = false;
        }


    }
}
